var errorBegin = "someerrorshappen";
/**
 * 自定义trim方法
 * 
 * @return
 */
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, "");
}
/**
 * 自定义判空
 * 
 * 
 * @return
 */
String.prototype.isEmpty = function() {
	if (null == this || "" == this.trim())
		return true;
	else
		return false;
}

// 翻页函数
function jumpPage(pageNo, type) {
	var pn = jQuery("#pageNum");
	var frm = pn.parent("form");
	pageNo = "" + pageNo;
	//type==3时属于后台管理中不统计数据量的翻页
	if(type!='3'){
		var totalPage=jQuery("#totalPage").val();
		if(totalPage!=null && totalPage!='undefined' && parseInt(totalPage)< parseInt(pageNo)){
			return;
		}
	}
	var reg = /^[0-9]{1,20}$/;
	if (pageNo.isEmpty() || null == pageNo.match(reg)){
		//pageNo = 1;
		return;
	}
	pn.val(pageNo);
	// 设置每页显示多少条
	var ps = jQuery("#pageSize");
	//ps.val(jQuery("#ps").val());
	//alert(ps.val());
	if (1 == type || 3 == type) {
		var url = frm.attr("action");
		var data = frm.serialize();
		delay("content");
		jQuery.ajax( {
			url : url,
			type : "post",
			dataType : "html",
			data : data,
			success : function(msg) {
				jQuery("#content").html(msg);
			}
		});
	} else
		frm.submit();
}
function goPage(type) {
	var pageNo = document.getElementById("pn").value;
	jumpPage(pageNo, type);
}
function goPage2(type) {
	var pageNo = document.getElementById("pn2").value;
	jumpPage(pageNo, type);
}
function changePage(type) {
	var ps = jQuery("#pageSize");
	ps.val(jQuery("#ps").val());
	jumpPage(1, type);
}
// 翻页函数----end

/**
 * 处理XML文件的一些方法-----开始
 */
function getNodeText(node) {
	try {
		if (node.childNodes.length == 0) {
			return node.nodeValue;
		}
		return getNodeText(node.childNodes[0]);
	} catch (err) {
		return "";
	}
}
function nodeParser(node) {
	var hProperties = new Properties();
	try {
		var nSize = node.childNodes.length;
		for ( var i = 0; i < nSize; i++) {
			if (node.childNodes[i].nodeType != 1)
				continue;
			var sPropName = node.childNodes[i].nodeName.toUpperCase();
			var sValue = getNodeText(node.childNodes[i]);
			if (sValue == null)
				sValue = "";
			hProperties.setProperty(sPropName, sValue);
		}
	} catch (err) {
		// alert(err.message);
	}
	return hProperties;
}

/**
 * 定义数组
 */
function ArrayList() {

	/* Define Private Properties Start */
	var arContainer = [];
	/* Define Private Properties End */

	/* Define Public Method Start */
	this.add = function(e) {
		arContainer[arContainer.length] = e;
	}
	this.addAll = function(list) {
		if (typeof list != "ArrayList")
			return false;
		var arList = list.toArray();
		for ( var i = 0; i < arList.length; i++)
			arContainer[arContainer.length] = arList[i];
		return true;
	}
	/*
	 * this.addAll = function(index, list){ //不支持 }
	 */
	this.clear = function() {
		arContainer = [];
	}
	this.contains = function(e) {
		for ( var i = 0; i < arContainer.length; i++)
			if (e == arContainer[i])
				return true;
		return false;
	}
	this.get = function(index) {
		try {
			return arContainer[index];
		} catch (err) {
			return null;
		}
	}
	this.indexOf = function(e) {
		for ( var i = 0; i < arContainer.length; i++)
			if (e == arContainer[i])
				return i;
		return -1;
	}
	this.isEmpty = function(e) {
		return arContainer.length == 0 ? true : false;
	}
	this.lastIndexOf = function(e) {
		for ( var i = arContainer.length - 1; i > 0; i--)
			if (e == arContainer[i])
				return i;
		return -1;
	}
	this.remove = function(index) {
		var e = this.get(index);
		if (e != null) {
			var p = index;
			for ( var q = p + 1; q < arContainer.length; q++, p++) {
				arContainer[p] = arContainer[q];
			}
			arContainer.length--;
		}
		return e;
	}
	/*
	 * this.remove = function(e){ var p = this.indexOf(e); return
	 * this.remove(p)==null ? false : true; }
	 */
	this.set = function(index, e) {
		try {
			arContainer[index] = e;
			return arContainer[index];
		} catch (err) {
			return null;
		}
	}
	this.size = function() {
		return arContainer.length;
	}
	this.toArray = function() {
		return arContainer;
	}
	// 谢尔排序
	this.sort = function() {
		for ( var step = arContainer.length >> 1; step > 0; step >>= 1) {
			for ( var i = 0; i < step; ++i) {
				for ( var j = i + step; j < arContainer.length; j += step) {
					var k = j, value = arContainer[j];
					while (k >= step && arContainer[k - step] > value) {
						arContainer[k] = arContainer[k - step];
						k -= step;
					}
					arContainer[k] = value;
				}
			}
		}
	}
	/* Define Public Method End */
}

// 清空检索词 dcoument.frmSearch.keyword
function setKwEmpty() {
	document.getElementById('searchword').value = '';
	document.getElementById('searchword').focus();
}

// 清空
function setEmpty(id) {
	if (!id.isEmpty()) {
		var t = $(id);
		t.clear();
		t.focus();
	}
}

// 格式 2000 OR 2000 to 2007
var year2SQL = function(s, e) {
	var y = new Array();
	if (!s.blank())
		y.push(s)
	if (!e.blank())
		y.push(e)
	if (y.length == 2 && s == e)
		y.pop();
	var r = "";
	if (y.length == 0)
		r = "";
	else if (y.length == 1)
		r = "DP='" + y[0] + "'";
	else
		r = "DP>='" + y[0] + "' and DP<'" + (parseInt(y[1]) + 1) + "'";
	return r;
}
// 格式 2000 OR 2000-2007
var year2Disp = function(s, e) {
	var y = new Array();
	if (!s.blank())
		y.push(s)
	if (!e.blank())
		y.push(e)
	if (y.length == 2 && s == e)
		y.pop();
	var r = "";
	for ( var i = 0; i < y.length; i++)
		r += "-" + y[i];
	if (r.length > 1)
		r = r.substring(1);
	return r;
}

/**
 * 获取checkbox选中的值，多个用","隔开
 * 
 * @param name
 *            名称
 * @return
 */
function getCBValues(name) {
	var values = "";
	var objs = document.getElementsByName(name);
	if (objs && 0 < objs.length) {
		for ( var i = 0; i < objs.length; i++) {
			if (objs[i].checked) {
				values += "," + objs[i].value;
			}
		}
		values = values.substring(1);
	}
	return values;
}

/**
 * 获取checkbox未选中的值，多个用","隔开
 * 
 * @param name
 *            名称
 * @return
 */
function getNCBValues(name) {
	var values = "";
	var objs = document.getElementsByName(name);
	if (objs && 0 < objs.length) {
		for ( var i = 0; i < objs.length; i++) {
			if (!objs[i].checked) {
				values += "," + objs[i].value;
			}
		}
		values = values.substring(1);
	}
	return values;
}

/**
 * 全选checkbox
 * @param allid 全选按钮的id
 * @param name 要全选的checkbox名称
 * 
 * @return 全选成功返回true，取消全选或者全选失败返回false
 */
function selectAll(allid, name) {
	var objs = document.getElementsByName(name);
	if (objs && 0 < objs.length) {
		if (jQuery("#" + allid).attr("checked") == true) {
			for ( var i = 0; i < objs.length; i++) {
				if (objs && 0 < objs.length) {
					objs[i].checked = true;
				}
			}
			return true;
		} else {
			for ( var j = 0; j < objs.length; j++) {
				if (objs && 0 < objs.length) {
					objs[j].checked = false;
				}
			}
			return false;
		}
	}
	return false;
}

/**
 * 切换内容
 * 
 * @param showId 切换内容的元素id
 * @param url 目标url
 * @param method 方法
 * @return
 */
function doChange(showId, url, method) {
	delay(showId);
	jQuery.ajax( {
		url : url,
		type : "post",
		dataType : "html",
		data : "method=" + method,
		success : function(msg) {
			$("#" + showId).html(msg);
		}
	});
}

/**
 * 通用切换内容
 * 
 * @param showId 切换内容的元素id
 * @param url 目标url
 * @param params 参数
 * @return
 */
//doCommonChange('content','/admin/group.do','method=open&id=${group.id }&userName=${f:escapeURL(group.ipUserName) }','main');
//doCommonChange('content','/admin/group.do','method=changePages&id=${group.id }&userName=${f:escapeURL(group.ipUserName) }','main');
function doCommonChange(showId, url, params) {
//	params=encodeURIComponent(params);
	delay(showId);
	jQuery.ajax( {
		url : url,
		type : "post",
		dataType : "html",
		data : params,
		success : function(msg) {
			$("#" + showId).html(msg);
		}
	});
}
/**
 * Ajax方式提交一个form
 * 
 * @param formName form Id
 * @param showId 返回结果显示的区域
 * @param dataType Ajax传输数据类型
 */
//ajaxSubmit('groupForm','content','html')
function ajaxSubmit(formId, showId, dataType) {
	var frm = jQuery("#" + formId);
	if (frm) {
		var action = frm.attr("action");
		var data = frm.serialize();
		jQuery.ajax( {
			url : action,
			type : "post",
			dataType : dataType,
			data : data,
			beforeSend : function() {
				delay(showId);
			},
			success : function(msg) {
				$("#" + showId).html(msg);
			}
		});
	}
}

/**
 * Ajax方式提交一个form，处理出错的情况
 * 
 * @param formName form Id
 * @param showId 返回结果显示的区域
 * @param dataType Ajax传输数据类型
 */
function ajaxSubmitDE(formId, showId, dataType) {
	var frm = jQuery("#" + formId);
	if (frm) {
		var action = frm.attr("action");
		var data = frm.formSerialize();
		jQuery.ajax( {
			url : action,
			type : "post",
			dataType : dataType,
			data : data,
			//			beforeSend: function(){
			//				delay(showId);
			//			},
			success : function(msg) {
				if (0 == msg.indexOf(errorBegin)) {
					alert(msg.substr(errorBegin.length + 1));
					return;
				} else
					$("#" + showId).html(msg);
			}
		});
	}
}

/**
 * 删除
 * 
 * @param {Object} cbName 保存id的checkbox名
 * @param {Object} url 调用的controller地址
 * @param {Object} method 调用的方法
 * @param {Object} pageNo 当前页
 * @return {TypeName} 
 */
function delRecords(cbName, url, method, pageNo) {
	var ids = getCBValues(cbName);
	var count = 0;
	if (ids.isEmpty()) {
		alert("没有选中任何记录!");
		return;
	}
	var idsA = ids.split(",");
	count = idsA.length;
	if (confirm("确实要删除这" + count + "条记录吗?")) {
		jQuery.ajax( {
			type : "post",
			url : url,
			dataType : "text",
			data : "method=" + method + "&ids=" + ids,
			success : function(msg) {
				//if ("success" == msg) {
					jumpPage(pageNo, 1);
				//} else
				//	alert("该记录已被使用，请先删除相关信息！")
			}
		});
	}
}


	
	/**
 * 套餐名monthPrice的查找
 * 
 * @param obj
 * select 的值
 * @param showId
 * 更改页
 * @return
 */
	function changeMonthPrice(obj,showId)
	{
	obj.focus();
	var modeName = obj.options[obj.selectedIndex].value.replace(/\+/g,'%2B');
	
	jQuery.ajax( {
			url : "userPayMode.do",
			type : "post",
			data : "method=changeMonthPrice&modeName=" + modeName ,
			success : function(msg) {
				$("#" + showId).html(msg);
			}
		});
	
}
	/**
 * 套餐名更改权限查找
 * 
 * @param obj
 * select 的值
 * @param showId
 * 更改页
 * @return
 */
	function changePayRights(obj,showId)
	{
	obj.focus();
	var modeName = obj.options[obj.selectedIndex].value.replace(/\+/g,'%2B');
	jQuery.ajax( {
			url : "userPayMode.do",
			type : "post",
			data : "method=changePayRights&modeName=" + modeName ,
			success : function(msg) {
				$("#" + showId).html(msg);
			}
		});
	
}

	/**
 * 套餐名更改权限查找
 * 
 * @param obj
 * select 的值
 * @param showId
 * 更改页
 * @return
 */
	function delUserPayMode(id,userType,userName)
	{
	var buf = "确实要删除吗?";
	if (window.confirm(buf)) {
	jQuery.ajax( {
			url : "userPayMode.do",
			type : "post",
			data : "method=delMode&id=" + id ,
			success : function(msg) {
				if ("success" == msg) {
					if(userType=="0"){
//					    doChange("content", "userManager.do", "person");
						doChange("content", "/admin/userManager.do", "showAll&userType="+userType+"&userName="+userName);
				    }else{
				    	doChange("content", "/admin/group.do", "AllGroup&groupName="+userName);
					}
				} else {
					alert("对不起,删除失败!");
				}
			}
		});}
}
/***
 * 更改用户套餐信息
 * updateUserPayMode('updatePay', 'content', 'html',${userType },${userName })
 */	
function updateUserPayMode(formId, showId, dataType, userType, userName)
{
	var frm = jQuery("#" + formId);
	if (frm) {
		var action = frm.attr("action");
		var data = frm.serialize();
//		data=encodeURIComponent(data);
		jQuery.ajax( {
			url : action,
			type : "post",
			dataType : dataType,
			data : data,
			success : function(msg) {
				if ("success" == msg) {
				    if(userType=="0"){
					      doChange("content", "/admin/userManager.do", "showAll&userType="+userType+"&userName="+userName);
				    }else{
					      doChange("content", "/admin/group.do", "AllGroup&groupName="+userName);
					}
				} else {
					alert("对不起,修改失败!");
				}
			}
		});
	}
}

/**
 * 修改个人用户角色后跳转到详细信息页面
 */
function updateUserPurview(formId, showId, dataType, userType, userName)
{
	var frm = jQuery("#" + formId);
	if (frm) {
		var action = frm.attr("action");
		var data = frm.formSerialize();
//		data=encodeURIComponent(data);
		jQuery.ajax( {
			url : action,
			type : "post",
			dataType : dataType,
			data : data,
			success : function(msg) {
				if ("success" == msg) {
//				    if(userType=="0"){
					      doChange("content", "/admin/userManager.do", "showAll&userType="+userType+"&userName="+userName);
//				    }else{
//					      doChange("content", "group.do", "showAll");
//					}
				} else {
					alert("对不起,修改失败!");
				}
			}
		});
	}
}
/**
*修改集团用户角色后跳转到集团用户细览页
*/
//updateGroupPurview('form12', 'content', 'html');
//groupPurview.do
//action = /admin/groupPurview.do?method=update&name=${userName }
function updateGroupPurview(formId, showId, dataType, groupName)
{
	var frm = jQuery("#" + formId);
	if (frm) {
		var action = frm.attr("action");
		var data = frm.formSerialize();
//		data=encodeURIComponent(data);
		jQuery.ajax( {
			url : action,
			type : "post",
			dataType : dataType,
			data : data,
			success : function(msg) {
				if ("success" == msg) {
					doChange("content", "/admin/group.do", "AllGroup&groupName="+groupName);
				} else {
					alert("对不起,修改失败!");
				}
			}
		});
	}
}
/**
*增加用户套餐后跳转到用户套餐概览页
*/
function updatePayMode(formId, showId, dataType)
{
	var frm = jQuery("#" + formId);
	if (frm) {
		var action = frm.attr("action");
		var data = frm.formSerialize();
		jQuery.ajax( {
			url : action,
			type : "post",
			dataType : dataType,
			data : data,
			success : function(msg) {
					doChange("content", "payMode.do", "showAll");
			}
		});
	}
}

function delNewsUpdate(id)
	{
	var buf = "确实要删除吗?";
	if (window.confirm(buf)) {
	jQuery.ajax( {
			url : "newsUpdates.do",
			type : "post",
			data : "method=del&id=" + id ,
			success : function(msg) {
				if ("success" == msg) {
					doChange("content", "newsUpdates.do", "open");
				} else {
					alert("对不起,删除失败!");
				}
			}
		});}
}

/**
 * 删除
 * 
 * @param {Object} cbName 保存id的checkbox名
 * @param {Object} url 调用的controller地址
 * @param {Object} method 调用的方法
 * @param {Object} pageNo 当前页
 * @return {TypeName} 
 */
function delPayModes(cbName, url, method, pageNo) {
	var ids = getCBValues(cbName);
	var count = 0;
	if (ids.isEmpty()) {
		alert("没有选中任何记录!");
		return;
	}
	var idsA = ids.split(",");
	count = idsA.length;
	if (confirm("确实要删除这" + count + "条记录吗?")) {
		jQuery.ajax( {
			type : "post",
			url : url,
			dataType : "text",
			data : "method=" + method + "&mdids=" + ids,
			success : function(msg) {
					
				if("empt"==msg){
				alert("套餐已经设置权限或已被使用，不可删除！")
				}
				else if("success"==msg){
				doChange("content", "payMode.do", "showAll");
				}else
				{
					alert("套餐修改失败！");
				}
			}
		});
	}
}
//首页选库检索
function firstPageSearch(){
		var frm=document.frmSearch;
		var searchword=frm.searchword;
		if(searchword.value==null||searchword.value==""){
			 jQuery.messager.alert('&nbsp;','请输入检索词！')
			return false;
		}
		var arr=$(":checkbox");
		var count=0;
		for(var i=0;i<arr.length;i++){
			if(arr[i].checked){
				count++;
			};
		}
		//如果选择多库则进入跨库检索
		if(count>1){
			frm.action="crossSearch.do";	
			return true;
		} 
		//如果选择单个库则进入对应库检索	
		if(count==1){
				for(var i=0;i<arr.length;i++){
					if(arr[i].checked){
						frm.action=arr[i].value+"/basicSearch.do";
						return true;
					}
				}
		}
		//都不选则提示用户选择数据库
		if(count==0){
			 jQuery.messager.alert('&nbsp;','请选择数据库！')
			return false;
		}

}
//首页高级检索
function advanceSearchOfIndex(){
		var arr=$(":checkbox");
		var count=0;
		for(var i=0;i<arr.length;i++){
			if(arr[i].checked){
				count++;
			};
		}
		//如果选择多库则进入跨库高级页面
		if(count>1){
			window.location.href="cross/advancedSearch.html";
		} 
		//如果选择单个库则进入对应库高级页面
		if(count==1){
				for(var i=0;i<arr.length;i++){
					if(arr[i].checked){
						window.location.href=arr[i].value+"/advancedSearch.html";
					}
				}
		}
		//都不选则提示用户选择数据库
		if(count==0){
			 jQuery.messager.alert('&nbsp;','请选择数据库！')
		}

}
//后台验证IP是否注册过
 function checkIP(isClick,formId, showId, dataType){
	var sure=document.getElementById("sure");
  	var ip=document.getElementById("registIP").value;
  	var reg=/^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
  	if(ip.length==0){
  		jQuery.messager.alert('&nbsp;',"IP不能为空！");
  		sure.disabled=true;
  		return;
  	}else{
  		//验证单个IP是否合法IP
  		var ips=ip.split(";");
  		for(var j=0;j<ips.length;j++){
  			if(ips[j].indexOf("*")==-1&ips[j].indexOf("-")==-1){
  				if(!reg.test(ips[j])){
			  		jQuery.messager.alert('&nbsp;',ips[j]+'不是有效的IP！');
					sure.disabled=true;
					return;
	  			}else{
	  				sure.disabled=false;
	  			}
  			}
  		}
  	}
  	var ipUserName=document.getElementById("ipUserName").value;
	 if(isClick==0){
		  ajaxSubmit(formId, showId, dataType);
	 }
	 if(isClick==1){
	  jQuery.ajax( {
				url : "/admin/group.do?method=checkIP",
				type : "post",
				dataType : "String",
				data :"registIP="+ip,
				success : function(msg) {
						if(msg!="noRegist"){
								if(msg.length>200){
									msg=msg.substring(0,200);
									var ips=msg.split("；");
									var msg="";
									for(var i=0;i<ips.length-2;i++){
										msg+=ips[i]+";";
									}
									if(msg.indexOf(ipUserName)==0){
										jQuery.messager.alert('&nbsp;','以下IP已经注册，请认真检查IP！');
			    						sure.disabled=true;
									}
									if(msg.indexOf(ipUserName)==-1){
										jQuery.messager.alert('&nbsp;','以下IP已经注册，请认真检查IP！');
			    						sure.disabled=true;
									}
								}else{
									if(msg.indexOf(ipUserName)==0){
										jQuery.messager.alert('&nbsp;','以下IP已经注册，请认真检查IP！');
			    						sure.disabled=true;
									}
									if(msg.indexOf(ipUserName)==-1){
											jQuery.messager.alert('&nbsp;','以下IP已经注册，请认真检查IP！');
											sure.disabled=true;
									}
								}
						}else{
								sure.disabled=false;
						}
				}
			});
	 }
  }
 //判读是否登录去下载中心
 function checkDownload(user){
   if(user == null || user == ''){
      window.location.href = "/login.do";
   }else{
        window.open( "/download.do");
   }
}
 //验证是否输入检索词
 function ckeckSearch(){
		var frm=document.frmSearch;
		var searchword=frm.searchword;
		if(searchword.value==null||searchword.value==""){
			 jQuery.messager.alert('&nbsp;','请输入检索词！')
			return false;
		}
}
 
 /**
  * 等待ing...
  * 
  * @param id 对应的元素id
  * @param htmlContent 显示的内容，可以不传这个参数，将显示默认内容
  * @return
  */
 function delay(id, htmlContent) {
 	if (id && !id.isEmpty()) {
 		if (htmlContent && !htmlContent.isEmpty()) {
 			jQuery("#" + id).html(htmlContent);
 		} else {
 			// 默认情况下的显示
 			jQuery("#" + id)
 					.html(
 							"<div align=center><img src='resources/images/spinner.gif'></img><div>");
 		}
 	}
 } 
//首页选库全选/反选
function selectAllDatabase(){
	if(jQuery("#selectAll").attr("checked") == true){
		jQuery("input[name=renyuan]").attr("checked",true);
		jQuery("input[name=anshijian]").attr("checked",true);
		jQuery("input[name=wupin]").attr("checked",true);
		jQuery("input[name=dizhi]").attr("checked",true);
		jQuery("input[name=zuzhi]").attr("checked",true);
		jQuery("input[name=gawxx]").attr("checked",true);
		jQuery("input[name=xgxx]").attr("checked",true);
	}
	if(jQuery("#selectAll").attr("checked") == false){
		jQuery("input[name=renyuan]").attr("checked",false);
		jQuery("input[name=anshijian]").attr("checked",false);
		jQuery("input[name=wupin]").attr("checked",false);
		jQuery("input[name=dizhi]").attr("checked",false);
		jQuery("input[name=zuzhi]").attr("checked",false);
		jQuery("input[name=gawxx]").attr("checked",false);
		jQuery("input[name=xgxx]").attr("checked",false);
	}
}
//人员全选/反选
function selectAllRenyuan(){
	if(jQuery("#renyuan").attr("checked") == true){
		jQuery("input[name=renyuan]").attr("checked",true);
	}
	if(jQuery("#renyuan").attr("checked") == false){
		jQuery("input[name=renyuan]").attr("checked",false);
	}
}
//按事件全选/反选
function selectAllAnshijian(){
	if(jQuery("#anshijian").attr("checked") == true){
		jQuery("input[name=anshijian]").attr("checked",true);
	}
	if(jQuery("#anshijian").attr("checked") == false){
		jQuery("input[name=anshijian]").attr("checked",false);
	}
}
//物品全选/反选
function selectAllWupin(){
	if(jQuery("#wupin").attr("checked") == true){
		jQuery("input[name=wupin]").attr("checked",true);
	}
	if(jQuery("#wupin").attr("checked") == false){
		jQuery("input[name=wupin]").attr("checked",false);
	}
}
//地址全选/反选
function selectAllDizhi(){
	if(jQuery("#dizhi").attr("checked") == true){
		jQuery("input[name=dizhi]").attr("checked",true);
	}
	if(jQuery("#dizhi").attr("checked") == false){
		jQuery("input[name=dizhi]").attr("checked",false);
	}
}
//组织全选/反选
function selectAllZuzhi(){
	if(jQuery("#zuzhi").attr("checked") == true){
		jQuery("input[name=zuzhi]").attr("checked",true);
	}
	if(jQuery("#zuzhi").attr("checked") == false){
		jQuery("input[name=zuzhi]").attr("checked",false);
	}
}
//公安网信息全选/反选
function selectAllGawxx(){
	if(jQuery("#gawxx").attr("checked") == true){
		jQuery("input[name=gawxx]").attr("checked",true);
	}
	if(jQuery("#gawxx").attr("checked") == false){
		jQuery("input[name=gawxx]").attr("checked",false);
	}
}
//相关信息全选/反选
function selectAllXgxx(){
	if(jQuery("#xgxx").attr("checked") == true){
		jQuery("input[name=xgxx]").attr("checked",true);
	}
	if(jQuery("#xgxx").attr("checked") == false){
		jQuery("input[name=xgxx]").attr("checked",false);
	}
}

/**
 * 初始化更多条件选项
 * @param sameType
 * @param more
 */
function initShowMore(sameType, more) {
	$(".showmore").unbind("click");
	$(".showmore").bind("click", function(){
		var element = $(this).parent().parent();
		if($(element).attr("show") == "show") {
			$(element).height("92px");
			$(element).removeAttr("show");
			$(element).find(".terms").show();
		}else{
			$(element).height("30px");
			$(element).attr("show", "show");
			$(element).find(".terms").hide();
		}
	});
	
	$("#" + sameType + "_homeFlag").bind("click", function(){
		$(this).parent().parent().find(".search").click();
	});
	
	if (more != "true") {
		$("#" + sameType + " .showmore").click();
	}
}

/**
 * 更多条件过滤检索
 * @param element
 * @param sameType
 * @param dbType
 */
function filterSearch(webname, element, sameType, dbType) {
	var homeFlag = $("#" + sameType + "_homeFlag").attr("checked");
	var badFlag = $("#" + sameType + "_badFlag").attr("checked");
	var age_begin = $("#" + sameType + "_age_begin").val();
	var age_end = $("#" + sameType + "_age_end").val();
	var showmore = "false";
	if ($(element).parent().attr("display") != "none") {
		showmore = "true";
	}
	
	var filter = homeFlag + ";" + badFlag + ";" + age_begin + ";" + age_end + ";" + showmore;
	sameSearch(webname, dbType, sameType, $("#sfzhm").val(), filter);
}

function checkAge(elementId){
	if($.trim($("#"+elementId).val()) != ""){
		if($.trim($("#"+elementId).val())!="*"){
			var reg = /^[0-9]{1,3}$/;
			if($.trim($("#"+elementId).val())!='' && !$.trim($("#"+elementId).val()).match(reg)){
				alert("年龄应为0~150的数字,请重新输入");
				return;
			}
			if($("#"+elementId).val()>150){
				alert("年龄范围应为0~150,请重新输入");
				return;
			}
		}
	}
}

/**
 * 检索概览页翻页(trshybase数据以及珠海SIS系统犯罪嫌疑人数据)
 * @param {Object} pageNo页码
 * @param {Object} dbtype库名
 * @param {Object} selected是否是输入框翻页
 */
function changeDisplayAjax(webname,pageNo,dbtype,selected) {
	//隐藏筛选及关注
	$(".obox15").hide();
	if(webname==null){
		webname="";
	}
    var no = 1;
    var size = new Number(document.getElementById("totalPages_"+dbtype).value);
    if(pageNo != null && pageNo != ''){
        no = pageNo;
    }
    if(selected){
    	//输入框输入页数时用
    	var pn = document.getElementById("pn_"+dbtype).value;
    	if(pn!=null && pn!=""){
    		pn = $.trim(pn);
    	}
    	var reg = /^\d+$/;
    	if(!pn.match(reg)){
    		//pn = 1;
    		return;
    	}
    	no = pn;
    }
    if(no == null || no == '' || no < 1){
       no = 1;
    }
    if(no > size){
    	no = size;
    }
	var db = dbtype;
	var sql = document.getElementById("sql_"+dbtype).value;
	var pageSize = document.getElementById("ps_"+dbtype).value;
	var beginDate = $('#beginDate').val();
	var endDate = $('#endDate').val();
	
	//概览页面的时间选择与关系人分析中民航同行人里时间选ID会冲突
	var customExpr = $("#" + dbtype + "_customExpr").val();
	if($("#" + dbtype + "_customExpr").length > 0 && typeof customExpr!='undefined' && customExpr!='undefined'){
		beginDate = $('#' + dbtype + '_beginTime').val();
		endDate = $('#' + dbtype + '_endTime').val();
	}else{
		customExpr='';
	}
	var address = $('#address').val();
	var age = $('#age').val();
	var huji = $('#huji').val();
	var jiguan = $('#jiguan').val();
	var gender = $('#gender').val();
	var minzu = $('#minzu').val();
	var orderBy = $('#currentOrderBy').val();
	var pinyin = $("#pinyin").val();
	var more = $("#" + dbtype + "_more").val();
	var searchtype = $("#searchtype").val();
	//案件类型首页时间地域范围限制
	var anjianAddress = $("#anjianAddress").val();
	var anjianTime = $("#anjianTime").val();
	//展现模式参数
	var photoBasicSearch = $("#photoBasicSearch").val();
	var params = 'customExpr='+ encodeURIComponent(customExpr) + '&searchword=' + encodeURIComponent(sql)+
			"&anjianAddress="+encodeURIComponent(anjianAddress)+"&anjianTime="+anjianTime+'&dbtype='+db+
			"&searchtype="+searchtype+'&pinyin='+pinyin +'&pageNo='+no+'&pageSize='+pageSize+"&beginDate="+
			beginDate+"&endDate="+endDate+"&minzu="+encodeURIComponent(minzu)+"&address="+encodeURIComponent(address)+
			"&age="+encodeURIComponent(age)+"&huji="+encodeURIComponent(huji)+"&jiguan="+encodeURIComponent(jiguan)+
			"&gender="+encodeURIComponent(gender)+"&photoBasicSearch="+photoBasicSearch+"&orderBy="+orderBy+"&more="+more;  
	var actionUrl = webname+"/"+db+"/basicSearch.do";
	
	if(dbtype!=null && dbtype=='web'){
		actionUrl = webname+"/webSearch.do";
	}
	
	jQuery.ajax({type:"post", dataType:"html", url:actionUrl,data:params, beforeSend:function () {
		jQuery("#resultDisplay").html("<br/><center><img src='"+webname+"/images/loading-big.gif' border='0' alt='' title=''></center>");
		}, complete:function () {
		}, error:function () {
		}, success:function (msg) {
	  		jQuery("#resultDisplay").html(msg);
			changeDaohangResult2(dbtype,'','');
		}
	});
}
/**
 * 各库检索概览页列表导出
 */
function gotoOutlineExcel(dbtype){
	//概览页面的时间选择与关系人分析中民航同行人里时间选ID会冲突
	var customExpr = $("#" + dbtype + "_customExpr").val();
	if($("#" + dbtype + "_customExpr").length > 0 && typeof customExpr!='undefined' && customExpr!='undefined'){
		$('#beginDate_send').val($('#' + dbtype + '_beginTime').val());
		$('#endDate_send').val($('#' + dbtype + '_endTime').val());
	}else{
		customExpr='';
	}
	$('#customExpr_send').val(customExpr);
	document.getElementById("sendForm").submit();
}

/**
 * 同户等检索页翻页(trshybase数据),包含民航离港等关联信息
 * @param {Object} pageNo页码
 * @param {Object} dbtype库名
 * @param {Object} selected是否是输入框翻页
 * @param {Object} relevanceType关联类型
 * @param {Object} filter 更多条件过滤
 */
function changeSameDisplayAjax(webname,pageNo,dbtype,selected,relevanceType, filter, sfzhm) {
	if(webname==null){
		webname="";
	}
    var no = 1;
    var size = new Number(jQuery("#sametotalPages_"+relevanceType).val());
    if(pageNo != null && pageNo != ''){
        no = pageNo;
    }
    if(selected){
    	//输入框输入页数时用
    	var pn = jQuery("#samepn_"+relevanceType).val();
    	if(pn!=null && pn!=""){
    		pn = $.trim(pn);
    	}
    	var reg = /^\d+$/;
    	if(!pn.match(reg)){
    		//pn = 1;
    		return;
    	}
    	no = pn;
    }
    if(no == null || no == '' || no < 1){
       no = 1;
    }
    if(no > size){
    	no = size;
    }
	var db = dbtype;
	var pageSize = jQuery("#sameps_"+relevanceType).val();
	if(relevanceType==null || relevanceType==''){
		relevanceType = 'samePeople';
	}
	var searchcondition = '';
	searchcondition = getCondition(relevanceType);
	var orderBy = jQuery("#sameOrderBy_"+relevanceType).val();
	var sUrl = webname+"/"+dbtype+"/sameSearch.do?sfzhm="+ sfzhm +"&filter="+ filter +"&method=sameSearch&"+searchcondition+"&relevanceType="+relevanceType+'&pageNo='+no+'&pageSize='+pageSize+"&orderBy="+orderBy+"&radom="+Math.random();
	if(sUrl!=''){
		var propertyType = jQuery("#propertyType").val();
		if(propertyType!=null && propertyType!="" && propertyType!="undefined" && typeof propertyType!="undefined"){
			sUrl += "&propertyType=relations"; 
		}
		jQuery.ajax({
			type:"post", 
			dataType:"String", 
			url:sUrl, 
			beforeSend:function () {
				jQuery("#"+relevanceType).html("<br/><center><img src='"+webname+"/images/loading-big.gif' border='0' alt='' title=''></center>");
			}, 
			complete:function () {}, 
			error:function () {}, 
			success:function (msg) {
				jQuery("#"+relevanceType).html(msg);
			}
		});
	}
}

/**
 * 关联信息中民航订票、民航离港、铁路售票、同监狱等更多条件筛选时的翻页函数。
 * @param {Object} webname
 * @param {Object} pageNo
 * @param {Object} dbtype
 * @param {Object} selected
 * @param {Object} relevanceType
 * @param {Object} sfzhm
 */
function changeRelativeDisplayAjax(webname,pageNo,dbtype,selected,relevanceType, sfzhm) {
	if(webname==null){
		webname="";
	}
    var no = 1;
    var size = new Number(jQuery("#sametotalPages_"+relevanceType).val());
    if(pageNo != null && pageNo != ''){
        no = pageNo;
    }
    if(selected){
    	//输入框输入页数时用
    	var pn = jQuery("#samepn_"+relevanceType).val();
    	if(pn!=null && pn!=""){
    		pn = $.trim(pn);
    	}
    	var reg = /^\d+$/;
    	if(!pn.match(reg)){
    		//pn = 1;
    		return;
    	}
    	no = pn;
    }
    if(no == null || no == '' || no < 1){
       no = 1;
    }
    if(no > size){
    	no = size;
    }
	var db = dbtype;
	var pageSize = jQuery("#sameps_"+relevanceType).val();
	if(relevanceType==null || relevanceType==''){
		relevanceType = 'samePeople';
	}
	if(dbtype=="mhlgxx")
		datefield = "HBRQ";
	else if(dbtype=="mhdpxx")
		datefield = "CFRQ";
	else if(dbtype=="tlspxx")
		datefield = "RQSJ";
	else
		datefield = "RK_CSRQ";
	var sUrl = "";
	//获取筛选等通用参数
	var params = getFilterCondition(dbtype,relevanceType,sfzhm,datefield);
	if(dbtype=="mhlgxx"){
		sUrl = webname+"/"+dbtype+"/basicSearch.do?templete=search/db/basic/"+dbtype+"/outline_samePerson&"+params
		+'&pageNo='+no+'&pageSize='+pageSize+"&orderBy=-"+datefield+"&relevanceType=samePlane&radom="+Math.random();
	}else if(dbtype=="mhdpxx"){
		sUrl = webname+"/"+dbtype+"/basicSearch.do?templete=search/db/basic/"+dbtype+"/outline_samePerson&"+params
		+'&pageNo='+no+'&pageSize='+pageSize+"&orderBy=-"+datefield+"&relevanceType=sameDingPiao&radom="+Math.random();
	}else if(dbtype=="tlspxx"){
		sUrl = webname+"/"+dbtype+"/basicSearch.do?templete=search/db/basic/"+dbtype+"/outline_samePerson&"+params
		+'&pageNo='+no+'&pageSize='+pageSize+"&orderBy=-"+datefield+"&relevanceType=sameTlsp&radom="+Math.random();
	}else if(dbtype=="jyfxry"){
		sUrl = webname+"/"+dbtype+"/jyfxry/basicSearch.do?templete=search/db/basic/"+dbtype+"/outline_samePerson"
		+'&pageNo='+no+'&pageSize='+pageSize+"&relevanceType=sameJianYu&radom="+Math.random();
	}
	if(sUrl!=''){
		jQuery.ajax({
			type:"post", 
			dataType:"String", 
			url:sUrl, 
			beforeSend:function () {
			jQuery("#"+relevanceType).html("<br/><center><img src='"+webname+"/images/loading-big.gif' border='0' alt='' title=''></center>");
			}, 
			complete:function () {}, 
			error:function () {}, 
			success:function (msg) {
				jQuery("#"+relevanceType).html(msg);
			}
		});
	}
}

/**
 * 同乘机等分类统计翻页函数
 * @param webname
 * @param pageNo
 * @param dbtype
 * @param relevanceType
 * @param gotoPageFlag
 * @return
 */
function changeMhTimesDisplayAjax(webname, pageNo, dbtype, relevanceType, sfzhm, searchword, pageflag, gotoPageFlag) {
    if(gotoPageFlag){
    	var no = 1;
        var size = new Number(document.getElementById("mhtotalPages_"+dbtype+"_"+relevanceType).value);
    	//输入框输入页数时用
    	no = document.getElementById("mhpn_"+dbtype+"_"+relevanceType).value;
    	if(no!=null && no!=""){
        	no = $.trim(no);
    	}
    	var reg = /^\d+$/;
    	if(!no.match(reg)){
        	//no = 1;
    		return;
    	}
   		if(no == null || no == '' || no < 1){
   	       no = 1;
   	    }
   	    if(no > size){
   	    	no = size;
   	    }
   	 	pageNo = no;
    }
	var pagesql = $("#mhsql_" + dbtype+"_"+relevanceType).val();
	if(pagesql=='' || null==pagesql || typeof pagesql=='undefined' || pagesql=='undefined'){
		pagesql = "";
	}
	var listflag = $("#listflag_" + dbtype+"_"+relevanceType).val();
	if(listflag=='' || null==listflag || typeof listflag=='undefined' || listflag=='undefined'){
		listflag = "";
	}
	var returnpage = $("#returnpage_" + dbtype+"_"+relevanceType).val();
	if(returnpage=='' || null==returnpage || typeof returnpage=='undefined' || returnpage=='undefined'){
		returnpage = "";
	}
	//同出入境筛选参数
	var mzvalue = $("#mzvalue_" + dbtype+"_"+relevanceType).val();
	if(mzvalue=='' || null==mzvalue || typeof mzvalue=='undefined' || mzvalue=='undefined'){
		mzvalue = "";
	}
	var crjmdd = $("#crjmdd_" + dbtype+"_"+relevanceType).attr("checked");
	if(crjmdd=='' || null==crjmdd || typeof crjmdd=='undefined' || crjmdd=='undefined'){
		crjmdd = "false";
	}
	var crjrylb = $("#crjrylb_" + dbtype+"_"+relevanceType).val();
	if(crjrylb=='' || null==crjrylb || typeof crjrylb=='undefined' || crjrylb=='undefined'){
		crjrylb = "";
	}
	var crjjtfs = $("#crjjtfs_" + dbtype+"_"+relevanceType).val();
	if(crjjtfs=='' || null==crjjtfs || typeof crjjtfs=='undefined' || crjjtfs=='undefined'){
		crjjtfs = "";
	}
	//全文参数
	var trscvalue = $("#trscvalue_" + dbtype+"_"+relevanceType).val();
	if(trscvalue=='' || null==trscvalue || typeof trscvalue=='undefined' || trscvalue=='undefined'){
		trscvalue = "";
	}
	//分钟参数
	var minutevalue = $("#minutevalue_" + dbtype+"_"+relevanceType).val();
	if(minutevalue=='' || null==minutevalue || typeof minutevalue=='undefined' || minutevalue=='undefined'){
		minutevalue = "";
	}else{
		minutevalue = $.trim(minutevalue);
    	var reg = /^\d+$/;
    	if(!minutevalue.match(reg)){
    		return;
    	}else if(new Number(minutevalue)>60){
    		//最大上限设为60
    		minutevalue = 60;
    	}
    	minutevalue = new Number(minutevalue);
	}
	//铁路同乘车同车厢、发站、到站等参数
	var cxvalue = $("#cxvalue_" + dbtype+"_"+relevanceType).attr("checked");
	if(cxvalue=='' || null==cxvalue || typeof cxvalue=='undefined' || cxvalue=='undefined'){
		cxvalue = "false";
	}
	var fzvalue = $("#fzvalue_" + dbtype+"_"+relevanceType).attr("checked");
	if(fzvalue=='' || null==fzvalue || typeof fzvalue=='undefined' || fzvalue=='undefined'){
		fzvalue = "false";
	}
	var dzvalue = $("#dzvalue_" + dbtype+"_"+relevanceType).attr("checked");
	if(dzvalue=='' || null==dzvalue || typeof dzvalue=='undefined' || dzvalue=='undefined'){
		dzvalue = "false";
	}
	var lxvalue = $("#lxvalue_" + dbtype+"_"+relevanceType).val();
	if(lxvalue=='' || null==lxvalue || typeof lxvalue=='undefined' || lxvalue=='undefined'){
		lxvalue = "all";
	}
	cxvalue = cxvalue+";"+fzvalue+";"+dzvalue;
	//座位号参数
	var zhvalue = $("#zhvalue_" + dbtype+"_"+relevanceType).val();
	if(zhvalue=='' || null==zhvalue || typeof zhvalue=='undefined' || zhvalue=='undefined'){
		zhvalue = "";
	}else{
		zhvalue = $.trim(zhvalue);
    	var reg = /^\d+$/;
    	if(!zhvalue.match(reg)){
    		return;
    	}else if(new Number(zhvalue)>60){
    		//最大上限设为60
    		zhvalue = 60;
    	}
    	zhvalue = new Number(zhvalue);
	}
	//民航同订票参数
	var mhdpxdmc = $("#mhdpxdmc_" + dbtype+"_"+relevanceType).val();
	if(mhdpxdmc=='' || null==mhdpxdmc || typeof mhdpxdmc=='undefined' || mhdpxdmc=='undefined'){
		mhdpxdmc = "";
	}
	var url = webname + "/" + dbtype
			+ "/sameSearch.do?method=sameSearchAll&relevanceType="
			+ relevanceType + "&pageSql=" + encodeURIComponent(pagesql)
			+ "&pageflag=" + pageflag + "&minutevalue=" + minutevalue
			+ "&cxvalue=" + cxvalue + "&zhvalue=" + zhvalue
			+ "&crjmdd=" + crjmdd + "&crjrylb=" + crjrylb + "&crjjtfs=" + crjjtfs
			+ "&mhdpxdmc=" + encodeURIComponent(mhdpxdmc)
			+ "&mzvalue=" + encodeURIComponent(mzvalue) + "&listflag="
			+ listflag + "&trscvalue=" + encodeURIComponent(trscvalue)
			+ "&lxvalue=" + encodeURIComponent(lxvalue)
			+ "&pageNo=" + pageNo + "&sfzhm=" + sfzhm + "&searchword="
			+ encodeURIComponent(searchword);
	if(returnpage!=null && returnpage!=''){
		url = url + "&returnpage="+returnpage;
	}
	var propertyType = jQuery("#propertyType").val();
	if(propertyType!=null && propertyType!="" && propertyType!="undefined" && typeof propertyType!="undefined"){
		url += "&propertyType=relations"; 
	}
	jQuery.ajax({
		type:"post", 
		url:url,
		beforeSend:function () {
			jQuery("#"+relevanceType).html("<center><img src='"+webname+"/images/loading-big.gif' border='0' alt='' title=''></center>");
		}, 
		success:function (msg) {
			jQuery("#"+relevanceType).html(msg);
		}
	});
}

/**
 * 异地检索概览页翻页
 * @param {Object} pageNo页码
 * @param {Object} dbtype库名
 * @param {Object} selected是否是输入框翻页
 */
function changeDisplayAjaxAsyn(webname,pageNo,dbtype,relevanceType,pageSql,totalPages,pageSize,selected,distribute) {
	if(distribute==null){
		//分布式查询入口标记
		distribute = '';
	}
	if(webname==null){
		webname="";
	}
    var no = 1;
    var size = new Number(totalPages);
    if(pageNo != null && pageNo != ''){
        no = pageNo;
    }
    if(selected){
    	//输入框输入页数时用
    	var pn = document.getElementById("pn_"+dbtype).value;
    	no = pn;
    }
    if(no == null || no == '' || no < 1){
       no = 1;
    }
    if(no > size){
    	no = size;
    }
	var db = dbtype;
	var sql = pageSql;
	var pageSize = pageSize;
	var templete = $("#" + dbtype + "_templete").val();
	if($("#" + dbtype + "_templete").length <= 0 || typeof templete=='undefined' || templete=='undefined'){
		templete='';
	}
	if(relevanceType==null || relevanceType==''){
		templete='';
	}
	var params = '&templete='+ templete +'&distribute='+distribute+'&pageSql=' + encodeURIComponent(sql)+'&relevanceType='+relevanceType+'&dbtype='+db+'&pageNo='+no+'&pageSize='+pageSize;
	var actionUrl = webname+"/"+db+"/asynSearch.do";
	if(dbtype!=null && 'czrk;zzrk;wbsw;lgzs;tllk;zyry;gzdx;kkcl;lggl;swcs'.indexOf(dbtype)>=0){
		actionUrl = webname+"/"+db+"/asynSearch.do";
	}else{
		actionUrl = '';	
	}
	var elementId = relevanceType;
	if(relevanceType==null || relevanceType==''){
		elementId = 'resultDisplayAsyn';
	}
	if(actionUrl!=''){
		jQuery.ajax({type:"post", dataType:"html", url:actionUrl,data:params, beforeSend:function () {
			jQuery("#"+elementId).html("<br/><center><img src='"+webname+"/images/loading-big.gif' border='0' alt='' title=''></center>");
			}, complete:function () {
			}, error:function () {
			}, success:function (msg) {
		  		jQuery("#"+elementId).html(msg);
			}
		});
	}
}

/**
 * 关联信息默认同户检索函数
 * @param {Object} webname应用名称
 * @param {Object} dbtype库名
 * @param {Object} ZZ要检索的住址
 */
function sameSearchDefault(webname, dbtype, RK_ZZ, jg, org, sfzhm){
	if(RK_ZZ==null || RK_ZZ==''){
		RK_ZZ = jQuery("#RK_ZZ").val();
	}
	var sUrl = webname + "/" + dbtype + "/sameSearch.do?org="+ encodeURIComponent(org) +"&jg="+ encodeURIComponent(jg) +"&RK_ZZ="+encodeURIComponent(RK_ZZ)+"&sfzhm="+encodeURIComponent(sfzhm)+"&radom="+Math.random();
	return sUrl;
}

function sameSearchJianyu(webname, dbtype, JY, sfzhm){
	var sUrl = webname + "/" + dbtype + "/sameSearch.do?jianyu="+encodeURIComponent(JY)+"&sfzhm="+encodeURIComponent(sfzhm)+"&radom="+Math.random();
	return sUrl;
}

function sameSearchPlane(webname, dbtype, zjbgsbm, zjsj, hkgsbm, planenumber, date, sfzhm) {
	var sUrl = webname + "/" + dbtype + "/sameSearch.do?zjbgsbm="+encodeURIComponent(zjbgsbm)+"&zjsj="+encodeURIComponent(zjsj)+"&hkgsbm="+encodeURIComponent(hkgsbm)+"&planenumber="+encodeURIComponent(planenumber)+"&date="+encodeURIComponent(date)+"&sfzhm="+encodeURIComponent(sfzhm)+"&radom="+Math.random();
	return sUrl;
}

//关系人分析民航离港等时间范围检索函数
function rankFilter(webname,dbtype,relevanceType, datefield) {
	var sfzhm = $("#sfzhm").val();
	//20140903此函数与对应翻页函数changeRelativeDisplayAjax中筛选参数等通用参数提取到单独函数中
	var params = getFilterCondition(dbtype,relevanceType,sfzhm,datefield);
	var surl = webname+"/"+dbtype+"/basicSearch.do?templete=search/db/basic/"+dbtype+"/outline_samePerson&more=true"
				+"&"+params + "&orderBy=-"+datefield+"&radom=" + Math.random();
	jQuery.ajax( {
		type : "post",
		dataType:"String", 
		url : surl,
		beforeSend:function () {
		jQuery("#"+relevanceType).html("<br/><center><img src='"+webname+"/images/loading-big.gif' border='0' alt='' title=''></center>");
		}, 
		complete:function () {}, 
		error:function () {}, 
		success : function(msg) {
			jQuery("#"+relevanceType).html(msg);
		}
	});
}

/**
 * 关系人分析民航离港等时间范围等筛选参数获取方法(将翻页与刚进入时完全相同条件提取为一个函数)
 * @param dbtype
 * @param relevanceType
 * @param sfzhm
 * @param datefield
 * @return
 */
function getFilterCondition(dbtype,relevanceType,sfzhm,datefield){
	var beginDate = $("#"+dbtype+"_beginTime").val();
	if(beginDate=='' || null==beginDate || typeof beginDate=='undefined' || beginDate=='undefined'){
		beginDate = "";
	}
	var endDate = $("#"+dbtype+"_endTime").val();
	if(endDate=='' || null==endDate || typeof endDate=='undefined' || endDate=='undefined'){
		endDate = "";
	}
	var customExpr = "SFZHM:" + sfzhm;
	//将默认时间[* TO *]条件去除,避免时间字段查询所有记录
	if(beginDate!="" && endDate!=""){
		customExpr = customExpr + " AND "+datefield+":[" + beginDate + " TO " + endDate + "]";
	}else if(beginDate!="" && endDate==""){
		customExpr = customExpr + " AND "+datefield+":[" + beginDate + " TO *]";
	}else if(beginDate=="" && endDate!=""){
		customExpr = customExpr + " AND "+datefield+":[* TO " + endDate + "]";
	}else{
		//都为空时不拼接时间字段
	}
	//20140116起始地,目的地参数添加
	var beginplace = $("#"+dbtype+"_beginplace").val();
	var beginplacefield = $("#"+dbtype+"_beginplace").attr("field");
	if (beginplace != null && beginplace!='undefined')
		beginplace = $.trim(beginplace);
	if ((beginplacefield!=null && beginplacefield!="") && (beginplace!=null && beginplace!="")){
		customExpr+=" AND "+beginplacefield+":"+beginplace;;
	}
	var endplace = $("#"+dbtype+"_endplace").val();
	var endplacefield = $("#"+dbtype+"_endplace").attr("field");
	if (endplace != null && endplace!='undefined')
		endplace = $.trim(endplace);
	if ((endplacefield!=null && endplacefield!="") && (endplace!=null && endplace!=""))
		customExpr+=" AND "+endplacefield+":"+endplace;
	//20140903全文筛选参数添加
	//全文参数
	var trscvalue = $("#trscvalue_" + dbtype+"_"+relevanceType).val();
	if(trscvalue!='' && null!=trscvalue && typeof trscvalue!='undefined' && trscvalue!='undefined'){
		customExpr+=" AND " + trscvalue;
	}else{
		trscvalue = "";
	}
	$("#"+dbtype+"_customExpr").val(customExpr);
	var params = "relevanceType="+relevanceType + "&beginDate="+beginDate+"&endDate="+endDate + "&beginplace="+encodeURIComponent(beginplace)
		+ "&endplace="+encodeURIComponent(endplace) + "&trscvalue="+encodeURIComponent(trscvalue)
		+ "&searchword=SFZHM:" + sfzhm + "&customExpr=" + encodeURIComponent(customExpr);
	return params;
}

/**
 * 关联信息检索函数
 * @param {Object} webname应用名称
 * @param {Object} dbtype库名
 * @param {Object} relevanceType关联类型，如同户、民航同行人
 * @param {Object} sfzhm点击时对应人的身份证号码
 * @param {Object} filter 更多条件过滤
 */
function sameSearch(webname, dbtype, relevanceType, sfzhm, filter){
	if(relevanceType==null || relevanceType==''){
		relevanceType = 'samePeople';
	}
	var searchcondition = '';
	searchcondition = getCondition(relevanceType);
	var sUrl = webname + "/" + dbtype + "/sameSearch.do?filter="+ filter +"&method=sameSearch&"+searchcondition+"&relevanceType="+encodeURIComponent(relevanceType)+"&sfzhm="+encodeURIComponent(sfzhm)+"&radom="+Math.random();
	//六维属性检索参数
	var propertyType = jQuery("#propertyType").val();
	if(propertyType!=null && propertyType!="" && propertyType!="undefined" && typeof propertyType!="undefined"){
		sUrl += "&propertyType=relations"; 
	}
	jQuery.ajax({
		type:"post", 
		dataType:"String", 
		url:sUrl, 
		beforeSend:function () {
			jQuery("#"+relevanceType).html("<br/><center><img src='"+webname+"/images/loading-big.gif' border='0' alt='' title=''></center>");
		}, 
		complete:function () {}, 
		error:function () {}, 
		success:function (msg) {
			jQuery("#"+relevanceType).html(msg);
		}
	});
}

/**
 * 根据关联类型获取参数
 * @param {Object} relevanceType关联类型
 */
function getCondition(relevanceType){
	var searchcondition = '';
	var RK_ZZ = '';
	var JG = $("#jg").val();
	var zjbgsbm = '';
	var zjsj = '';
	var hkgsbm = '';
	var planeNumber = '';
	var date = '';
	var organization = '';
	var jianyu = '';
	var linju = '';
	var cc = '';
	var rqsj = '';
	var dbtype='';
	if(relevanceType=='samePeople'){
		dbtype='renkou';
		RK_ZZ = jQuery("#RK_ZZ").val();
		if(RK_ZZ!=null && RK_ZZ!=''){
			searchcondition = "RK_ZZ="+encodeURIComponent(RK_ZZ);
		}
		if(JG!=null && JG!=''){
			searchcondition += "&JG="+encodeURIComponent(JG);
		}
	}else if(relevanceType=='samePlane'){
		dbtype = 'mhlgxx';
		planeNumber = jQuery("#planeNumber").val();
		if(planeNumber!=null && planeNumber!=''){
			searchcondition += "planeNumber="+encodeURIComponent(planeNumber);
		}
		date = jQuery("#date").val();
		if(date!=null && date!=''){
			searchcondition += "&date="+encodeURIComponent(date);
		}
		zjbgsbm = jQuery("#zjbgsbm").val();
		if(zjbgsbm!=null && zjbgsbm!=''){
			searchcondition += "&zjbgsbm="+encodeURIComponent(zjbgsbm);
		}
		zjsj = jQuery("#zjsj").val();
		if(zjsj!=null && zjsj!=''){
			searchcondition += "&zjsj="+encodeURIComponent(zjsj);
		}
		hkgsbm = jQuery("#hkgsbm").val();
		if(hkgsbm!=null && hkgsbm!=''){
			searchcondition += "&hkgsbm="+encodeURIComponent(hkgsbm);
		}
		
		if(JG!=null && JG!=''){
			searchcondition += "&JG="+encodeURIComponent(JG);
		}
	}else if(relevanceType=='sameDingPiao'){
		dbtype='mhdpxx';
		planeNumber = $("#planeNumber").val();
		if(planeNumber!=null && planeNumber!=''){
			searchcondition = "planeNumber="+encodeURIComponent(planeNumber);
		}
		date = $("#date").val();
		if(date!=null && date!=''){
			searchcondition += "&date="+encodeURIComponent(date);
		}
		
		if(JG!=null && JG!=''){
			searchcondition += "&JG="+encodeURIComponent(JG);
		}
	}else if(relevanceType=='sameOrganization'){
		dbtype='renkou';
		organization = jQuery("#organization").val();
		if(organization!=null && organization!=''){
			searchcondition = "organization="+encodeURIComponent(organization);
		}
		
		if(JG!=null && JG!=''){
			searchcondition += "&JG="+encodeURIComponent(JG);
		}
	}else if(relevanceType=='sameJianyu'){
		dbtype='jyfxry';
		jianyu = jQuery("#jianyu").val();
		if(jianyu!=null && jianyu!=''){
			searchcondition = "jianyu="+encodeURIComponent(jianyu);
		}
		
		if(JG!=null && JG!=''){
			searchcondition += "&JG="+encodeURIComponent(JG);
		}
	}else if(relevanceType=='sameLinju'){
		dbtype='renkou';
		linju = jQuery("#linju").val();
		if(linju!=null && linju!=''){
			searchcondition = "linju="+encodeURIComponent(linju);
		}
		
		if(JG!=null && JG!=''){
			searchcondition += "&JG="+encodeURIComponent(JG);
		}
	}else if(relevanceType=='sameLinju'){
		dbtype='mzbhyzjxx';
	}else if(relevanceType=='sameTlsp'){
		dbtype='tlspxx';
		cc = $("#cc").val();
		if(cc!=null && cc!=''){
			searchcondition = "cc="+encodeURIComponent(cc);
		}
		rqsj = $("#rqsj").val();
		if(rqsj!=null && rqsj!=''){
			searchcondition += "&rqsj="+encodeURIComponent(rqsj);
		}
		
		if(JG!=null && JG!=''){
			searchcondition += "&JG="+encodeURIComponent(JG);
		}
	}
	//全文字段参数
	var trscvalue = $("#trscvalue_" + dbtype+"_"+relevanceType).val();
	if(trscvalue!='' && null!=trscvalue && typeof trscvalue!='undefined' && trscvalue!='undefined'){
		searchcondition += "&trscvalue="+encodeURIComponent(trscvalue);
	}
	//分钟参数,差值,如铁路订票票号相差
	var minutevalue = $("#minutevalue_" + dbtype+"_"+relevanceType).val();
	if(minutevalue=='' || null==minutevalue || typeof minutevalue=='undefined' || minutevalue=='undefined'){
		minutevalue = "";
	}else{
		minutevalue = $.trim(minutevalue);
    	var reg = /^\d+$/;
    	if(!minutevalue.match(reg)){
    		return;
    	}else if(new Number(minutevalue)>60){
    		//最大上限设为60
    		minutevalue = 60;
    	}
    	minutevalue = new Number(minutevalue);
    	searchcondition += "&minutevalue="+minutevalue;
	}
	//车厢、发站、到站参数
	var cxvalue = $("#cxvalue_" + dbtype+"_"+relevanceType).attr("checked");
	if(cxvalue=='' || null==cxvalue || typeof cxvalue=='undefined' || cxvalue=='undefined'){
		cxvalue = "false";
	}
	var fzvalue = $("#fzvalue_" + dbtype+"_"+relevanceType).attr("checked");
	if(fzvalue=='' || null==fzvalue || typeof fzvalue=='undefined' || fzvalue=='undefined'){
		fzvalue = "false";
	}
	var dzvalue = $("#dzvalue_" + dbtype+"_"+relevanceType).attr("checked");
	if(dzvalue=='' || null==dzvalue || typeof dzvalue=='undefined' || dzvalue=='undefined'){
		dzvalue = "false";
	}
	var lxvalue = $("#lxvalue_" + dbtype+"_"+relevanceType).val();
	if(lxvalue=='' || null==lxvalue || typeof lxvalue=='undefined' || lxvalue=='undefined'){
		lxvalue = "all";
	}
	cxvalue = cxvalue+";"+fzvalue+";"+dzvalue;
	searchcondition += "&cxvalue="+cxvalue;
	searchcondition += "&lxvalue="+encodeURIComponent(lxvalue);
	//座位号参数
	var zhvalue = $("#zhvalue_" + dbtype+"_"+relevanceType).val();
	if(zhvalue=='' || null==zhvalue || typeof zhvalue=='undefined' || zhvalue=='undefined'){
		zhvalue = "";
	}else{
		zhvalue = $.trim(zhvalue);
    	var reg = /^\d+$/;
    	if(!zhvalue.match(reg)){
    		return;
    	}else if(new Number(zhvalue)>60){
    		//最大上限设为60
    		zhvalue = 60;
    	}
    	zhvalue = new Number(zhvalue);
    	searchcondition += "&zhvalue="+zhvalue;
	}
	return  searchcondition;
}

/**
 * 替换所有字符串
 * @param {Object} restr 原字符串
 * @param {Object} substr 要替换的源子串
 * @param {Object} destr 要替换的目标子串
 */
function replaceAllMySelf(restr, substr, destr){
	var flag = true;
	while(flag){
		restr = restr.replace(substr,destr);
		if(restr.indexOf(substr)<0){
			flag = false;
		}
	}
	return restr;
}

/**
 * 输入时间进行检索
 */
function timeSearchSubmit(){
	jQuery("#beginDate").val(jQuery("#beginTime").val());
	jQuery("#endDate").val(jQuery("#endTime").val());
	jQuery('#searchForm').submit();
}

/**
 * 表单提交时判断检索词是否为空
 */
function checkSearchword(formid){
	var searchtype = $("#searchtype").val();
	if(searchtype!=null && searchtype!='' && searchtype=='advsearch'){
		var lastq = $("#lastq").val();
		var word = $("#"+ formid + "_searchword").val();
		if(word!=lastq){
			//从高级检索进入到结果页,重新输入检索词后需要重新解析
			$("#searchtype").val('');
		}
	}
	//增加重点国家、重点航班入境人员、重点年龄段人员筛选
	var mainPersonParams = '';
	$("#mainPersonParamsDiv input[type=checkbox]").each(function(){
		var checked = $(this).attr('checked');
		if(checked=='' || null==checked || typeof checked=='undefined' || checked=='undefined'){
			checked = "false";
		}
		mainPersonParams+=";"+checked;
	});
	if(mainPersonParams!=null && mainPersonParams!=''){
		mainPersonParams = mainPersonParams.substring(1);
	}
	$("#mainPersonParams").val(mainPersonParams);
	var searchword = jQuery("#"+ formid + "_searchword").val();
	if((searchword==null || searchword=='') && mainPersonParams.indexOf('true')<0){
		jQuery('#' + formid).attr("action","index.do");
	}
	//勾选重点国家或重点航班入境或土耳其出入境人员时只查询该表
	var mainNation = $("#mainPersonParamsDiv input[type=checkbox][subtype=mainNation]").attr('checked');
	if(mainNation=='' || null==mainNation || typeof mainNation=='undefined' || mainNation=='undefined'){
		mainNation = "false";
	}
	var mainPlane = $("#mainPersonParamsDiv input[type=checkbox][subtype=mainPlane]").attr('checked');
	if(mainPlane=='' || null==mainPlane || typeof mainPlane=='undefined' || mainPlane=='undefined'){
		mainPlane = "false";
	}
	var teqCrjry = $("#mainPersonParamsDiv input[type=checkbox][subtype=teqCrjry]").attr('checked');
	if(teqCrjry=='' || null==teqCrjry || typeof teqCrjry=='undefined' || teqCrjry=='undefined'){
		teqCrjry = "false";
	}
	var sxdbs = "";
	if(mainPlane==true || teqCrjry==true){
		sxdbs = "crjjl;mhlgxx;mhdpxx";
	}else{
		if(mainNation==true){
			sxdbs = "crjjl";
		}
	}
	if(sxdbs!=null && sxdbs!=""){
		$("#"+formid+" input[name='dbs']").val(sxdbs);
	}
	jQuery('#' + formid).submit();
}

/**
 * 若输入框检索词不为空切换导航后进行检索。
 * @param {Object} type导航类型
 * @param {Object} req发送请求
 */
function changeDaohangSearch(type,req,searchwordid){
	var searchword = jQuery("#"+searchwordid).val();
	if(searchword!=null && searchword!=''){
		jQuery("#"+type).attr('href',req+"?searchword="+encodeURIComponent(searchword)+"&type="+encodeURIComponent(type)+"&radom="+Math.random());
		return true;
	}else{
		jQuery("#"+type).attr('href',req+"?type="+encodeURIComponent(type)+"&radom="+Math.random());
		return true;
	}
}

/**
 * 检索输入框获得焦点时显示检索提示
 * @param {Object} lj
 * @param {Object} ele
 * @param {Object} id
 */
function toOpenJj(lj, ele, id) {
	var jj = $('#JJ' + lj);
	var jc = $('#J'+id);
	var jjc = $('#JJC' + lj);
	var joffset = $(ele).offset();
	var top = joffset.top + 32;
	var left = joffset.left;
	if(lj=="R")
	left = joffset.left-$(jj).width()+35;
	$(jj).css("top",top).css("left",left); 
	$(jjc).html($(jc).html());
	$(jj).fadeIn("fast"); 
}

/**
 *  检索输入框失去焦点时检索提示不显示
 * @param {Object} lj不显示的对象ID
 */
function toCloseJj(lj) {
	$('#JJ' + lj).fadeOut("fast");
}

/**
 * 点击链接隐藏或显示div
 * @param {Object} type当前导航类型
 */
function selectDatabase(type){
	if(jQuery("#"+type).css("display")!='none'){
		jQuery("#"+type).fadeOut();
	}else{
		jQuery("#"+type).fadeIn();
	}
}

/**
 * 点击链接隐藏或显示div并切换背景
 * @param {Object} id当前类型
 * @param {Object} divs要折叠的div
 */
function changeDivBg(id,divs){
	if(jQuery("#"+id).css("display")!='none'){
		jQuery("#"+id).hide();
	}else{
		jQuery("#"+id).show();
	}
	if(divs!='' && divs!=null){
		var array=divs.split(";");
		for(var i=0;i<array.length;i++){
			if(array[i]!=id){
				jQuery("#"+array[i]).hide();
			}
		}
	}
}

/**
 * 弹出窗口
 * @param {Object} url弹出窗url
 * @param {Object} name弹出窗标题
 */
function showModalWin(url,name) {
	window.open(url,name,"height=500px,width=920px,top="+(screen.height-500)/2+",left="+(screen.width-920)/2+",toolbar=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,modal=yes");
}

/**
 * 切换首页自定义内容背景图
 * @param {Object} id对象id
 * @param {Object} attrname属性名
 * @param {Object} imgname图片名（包含路径）
 */
function changeMyContentBg(id, attrname,imgname){
	jQuery("#"+id+" img").attr(attrname,imgname);
}

/**
 * 选择复选框
 * @param parentid 选择按钮的id
 * @param classname 要勾选的checkbox类名
**/
function selectCheckbox(parentid, classname) {
	//var flag = jQuery("#" + parentid).attr("checked"); jQuery1.6之前版本
	var flag = $("#" + parentid).is(":checked"); 
	var objs = jQuery("." + classname);
	if (objs && 0 < objs.length) {
		if (flag == true) {
			for ( var i = 0; i < objs.length; i++) {
				if (objs && 0 < objs.length) {
					objs[i].checked = true;
				}
			}
			return true;
		} else {
			for ( var j = 0; j < objs.length; j++) {
				if (objs && 0 < objs.length) {
					objs[j].checked = false;
				}
			}
			return false;
		}
	}
	return false;
}

/**
 * 时间处理,特殊字符替换为空,不足14位补0,大于14位截取14位
 * @param strTime 时间字符串
 * @return 14位年月日时分秒格式时间
 */
function getFormatTime(strTime){
	var size = 0;
	if(strTime!=null && strTime!=''){
		strTime = strTime.replace(/-/g,"").replace(/\//g,"").replace(/ /g,"").replace(/:/g,"").replace(/\./g,"");
		size = strTime.length;
	}else{
		return "";
	}
	//不足14位自动补0
	if(size<14){
		for(var i=0;i<14-size;i++){
			strTime+="0";
		}
	}else if(size>14){
		strTime = strTime.substring(0,14);
	}
	return strTime;
}

/**
 * 将json返回的时间戳字符串转换为date类型
 * @param jsonDate
 * @returns
 */
function formatJSONDate(jsonDate) {
	var newDate = $.format.date(jsonDate, "yyyy-MM-dd HH:mm:ss");
  	return newDate;
}

function formatServerDate(jsonDate) {
	var newDate = $.format.date(jsonDate, "yyyy-MM-dd");
  	return newDate;
}

function pageHelper(pageNum,pages){
	var $pagination = $('#pagination');
	   var defaultOpts = {
	       totalPages: 10
	   };
	   $pagination.twbsPagination(defaultOpts);
	   $pagination.twbsPagination('destroy');
	   $pagination.twbsPagination($.extend({}, defaultOpts, {
	   	initiateStartPageClick: false,
	   	startPage: pageNum > 0 ? pageNum : 1,
	       totalPages: pages > 0 ? pages : 1,
	       first:"首页",
	       prev: "上一页",
	       next:"下一页",
	       last:"尾页",
	       loop:true,				//跳转到指定页数
	       visiblePages: pages > 10 ? 10 : pages,
	       onPageClick: function (event, page) {
	       	$("#pageNum").val(page);
	       	search();
	       }
	   }));
}